import PropTypes from 'prop-types'
import React from 'react'
// import CSSModules from '../lib/CSSModules'
// import styles from './NoteItemSimple.styl'
import i18n from '../lib/i18n'

/**
 * @description Note item component when using simple display mode.
 * @param {boolean} isActive
 * @param {Object} note
 * @param {Function} handleNoteClick
 * @param {Function} handleNoteContextMenu
 * @param {Function} handleDragStart
 */
const NoteItemSimple = ({
  isActive,
  isAllNotesView,
  note,
  handleNoteClick,
  handleNoteContextMenu,
  handleDragStart,
  pathname,
  storage
}) => (
  <div
    className={isActive ? 'item-simple--active' : 'item-simple'}
    style={{margin:"4px 4px 4px 4px"}}
    key={note.key}
    onClick={e => handleNoteClick(e, note.key)}
    onContextMenu={e => handleNoteContextMenu(e, note.key)}
    onDragStart={e => handleDragStart(e, note)}
    draggable='true'
  >
    <h4 className='item-simple-title'>
      {note.type === 'SNIPPET_NOTE' ? (
        <i className='item-simple-title-icon' className='fa fa-fw fa-code' />
      ) : (
        <i
          className='item-simple-title-icon'
          className='fa fa-fw fa-file-text-o'
        />
      )}
      {note.isPinned && !pathname.match(/\/starred|\/trash/) ? (
        <i className='item-pin' className='fa fa-thumb-tack' />
      ) : (
        ''
      )}
      {note.title.trim().length > 0 ? (
        note.title
      ) : (
        <span className='item-simple-title-empty'>{i18n.__('Empty note')}</span>
      )}
      {isAllNotesView && (
        <div className='item-simple-right'>
          <span className='item-simple-right-storageName'>{storage.name}</span>
        </div>
      )}
    </h4>
  </div>
)

NoteItemSimple.propTypes = {
  isActive: PropTypes.bool.isRequired,
  note: PropTypes.shape({
    storage: PropTypes.string.isRequired,
    key: PropTypes.string.isRequired,
    type: PropTypes.string.isRequired,
    title: PropTypes.string.isrequired
  }),
  handleNoteClick: PropTypes.func.isRequired,
  handleNoteContextMenu: PropTypes.func.isRequired,
  handleDragStart: PropTypes.func.isRequired
}

export default NoteItemSimple ;//CSSModules(NoteItemSimple, styles)
